// API代理前缀常量
const API_PREFIX = '/api';

// 统一的请求方法
const request = {
    get: async (url, params = {}) => {
        try {
            return await $.ajax({
                url: `${API_PREFIX}${url}`,
                method: 'GET',
                data: params
            });
        } catch (error) {
            throw new Error('请求失败');
        }
    },

    post: async (url, data = {}) => {
        try {
            return await $.ajax({
                url: `${API_PREFIX}${url}`,
                method: 'POST',
                contentType: 'application/json',
                data: JSON.stringify(data)
            });
        } catch (error) {
            throw new Error('请求失败');
        }
    }
}; 